﻿using System;

namespace Bilibili.Model.Live
{
    public sealed class LiveHistoryItemModel
    {
        public int Roomid { get; set; }
        public string Title { get; set; }
        public string Name { get; set; }
        public string Cover { get; set; }
        public string Tag_Name { get; set; }
        public long View_At { get; set; }
        public string ViewAt
        {
            get
            {
                DateTime dtStart = new DateTime(1970, 1, 1);
                TimeSpan toNow = TimeSpan.FromSeconds(View_At);
                DateTime dt = dtStart.Add(toNow).ToLocalTime();
                TimeSpan span = DateTime.Now - dt;
                if (span.TotalDays > 7)
                    return dt.ToString("yyyy-MM-dd");
                else if (span.TotalDays > 1)
                    return string.Format("{0}天前", (int)Math.Floor(span.TotalDays));
                else if (span.TotalHours > 1)
                    return string.Format("{0}小时前", (int)Math.Floor(span.TotalHours));
                else if (span.TotalMinutes > 1)
                    return string.Format("{0}分钟前", (int)Math.Floor(span.TotalMinutes));
                else if (span.TotalSeconds >= 1)
                    return string.Format("{0}秒前", (int)Math.Floor(span.TotalSeconds));
                else
                    return "1秒前";
            }
        }
        public string Uri { get; set; }
        public LiveHistoryItemHistoryModel History { get; set; }
    }
    public class LiveHistoryItemHistoryModel
    {
        public int Oid { get; set; }
    }
}